package com.day6.test7_lambda;

/**
 * @author 小坡
 * @date 2022/9/8  9:47
 **/
public class Test7Lambda {
    /*
     *
     * */
    public static void main(String[] args) {
        goSwimming(new Swimming() {
            @Override
            public void swim() {
                System.out.println("宝贝，我们去游泳吧~");
            }
        });
        /*
         * 理解：
         *   对于Lambda表达式，对匿名内部类进行了优化
         * */
        goSwimming(() -> {
            System.out.println("宝贝，我们去游泳吧~");
        });
    }

    //使用接口的方法
    public static void goSwimming(Swimming swimming) {
        swimming.swim();
    }
}

//游泳的接口
interface Swimming {
    void swim();
}
